package top.kaoshanji.p1ch04a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 代码清单-p1ch04a-83页a：中间操作
 * author kaoshanji
 * ^_^
 * create time 2025/2/10 19:26
 */
public class HighCaloriesNames {

    private static final Logger logger = LogManager.getLogger(HighCaloriesNames.class);

    public static void main(String[] args) {
        logger.info("...代码清单-p1ch04a-83页a：中间操作...");

        List<String> names = Dish.menu.stream()
                .filter(dish -> {
                    System.out.println("filtering " + dish.getName());
                    return dish.getCalories() > 300;
                })
                .map(dish -> {
                    System.out.println("mapping " + dish.getName());
                    return dish.getName();
                })
                .limit(3)
                .collect(Collectors.toList());

        System.out.println(names);
    }

}
